package com.lwj.designpattern.strategy;

/**
 * @author wujilee
 * @date 2023/2/13
 */
public class Sorter<T> {
    public    void sort(T[] arr,Compartor compartor){
        for (int i = 0; i < arr.length; i++) {
            int  minPos = i;
            for (int j = i+1 ; j < arr.length ;  j++) {
                minPos = compartor.compareTo( arr[j],arr[minPos]) == -1? j:minPos;
            }
        }
    }

    static  void swap( Comparable[] arr,int i,int j){
        Comparable o = arr[i];
        arr[i] = arr[j];
        arr[j] = o;
    }
}
